import 'package:flutter/material.dart';

class LoadingContainer extends StatelessWidget {
  final Widget child;
  final bool isLoading;
  final bool cover;

  const LoadingContainer(
      {super.key,
      required this.child,
      required this.isLoading,
      this.cover = false});

  @override
  Widget build(BuildContext context) {
    print("cover: $cover, isLoading:$isLoading");
    if (!cover) {
      print("isLoading:$isLoading");
      return isLoading ? _loadingView : child;
    }

    List<Widget> items = [child];
    if (isLoading) {
      items.add(_loadingView);
    }

    return Stack(
      children: items,
    );
  }

  Widget get _loadingView {
    return const Center(
      child: CircularProgressIndicator(),
    );
  }
}
